package com.suray.wcs.service.rescontact;

import com.suray.basic.wcs.path.core.Node;
import com.suray.basic.wcs.path.core.NodeToRes;
import com.suray.basic.wcs.path.core.Route;
import com.suray.basic.wcs.utils.Coord;
import com.suray.basic.wcs.utils.LoggerUtil;
import com.suray.basic.wcs.utils.WcsFuncUtil;
import com.suray.commin.core.redis.RedisCache;
import com.suray.commin.core.utils.SpringContextHolder;
import com.suray.wcs.res.enums.*;
import com.suray.wcs.res.msgparse.*;
import com.suray.wcs.res.service.rescontact.ActionOrder;
import com.suray.wcs.service.config.resolver.LogInterceptorRvg;
import com.suray.commin.annotation.RvgLog;
import com.suray.wcs.service.config.resolver.RgvLogRecorder;
import com.suray.wcs.service.core.util.LongConnSendUtilLora;
import com.suray.wcs.service.enums.CodeType;
import com.suray.wcs.res.enums.RgvType;
import com.suray.commin.exception.OrderExecuteException;
import com.suray.wcs.service.pojo.Rgv;
import com.suray.wcs.service.pojo.Rgv60;
import com.suray.wcs.service.pojo.RgvSM;
import com.suray.wcs.service.pojo.rgv.action.util.RgvActionStatus;
import com.suray.wcs.service.pojo.rgv.rgv.protocol.base.RgvBaseMessage;
import com.suray.wcs.service.pojo.rgv.rgv.protocol.message.*;
import com.suray.wcs.service.pojo.rgv.rgv.protocol.util.DebugCommType;
import com.suray.wcs.service.pojo.rgv.rgv.protocol.util.RgvMessageType;
import com.suray.wcs.service.pojo.sendmap.RgvFileSendSector;
import com.suray.wcs.service.resmap.MapMessageSend;
import com.suray.wcs.service.system.service.impl.CodeDBServiceImpl;
import com.suray.wcs.service.system.service.impl.NodeDBServiceImpl;
import com.suray.wcs.service.thread.WcsHeartThread;
import com.suray.wcs.service.util.WcsUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cglib.proxy.Enhancer;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class ToRes {
    CodeDBServiceImpl codeDBService = SpringContextHolder.getBean(CodeDBServiceImpl.class);
    private Logger log = LoggerFactory.getLogger(this.getClass());
    private static final Map<Rgv, ToRes> toResMap = new ConcurrentHashMap<>();
    private RedisCache redisCache = SpringContextHolder.getBean(RedisCache.class);
    private final Rgv rgv;
    private int rgvNo;

    protected ToRes(Rgv rgv) {
        this.rgv = rgv;
        this.rgvNo = rgv.getRgvDB().getRgvNo();
    }

    /**
     * 向Res更新地图
     *
     * @param filePath
     * @throws IOException
     * @throws FileNotFoundException
     */
    @RvgLog(value = "向Res更新地图")
    public void mapSend(Integer wcsTaskNo, String filePath) throws IOException {
        if (RgvType.FOUR_GENERATIONS.getValue() == rgv.getRgvDB().getRgvType()) {
            MapMessageSend.packData(filePath, rgv);
        } else if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
            RgvFileSendSector.sendFile(new FileInputStream(filePath), rgv, "ResPlus.map");
        }

    }

    /**
     * 向Res更新固件
     *
     * @param fileInputStream
     * @throws IOException
     * @throws FileNotFoundException
     */
//    @RvgInterfaceLog(value = "向Res更新固件")
    public void updateFirmware(String name, InputStream fileInputStream) throws IOException {
        if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
//            String name;
//            if (filePath.lastIndexOf("\\") > 0) {
//                name = filePath.substring(filePath.lastIndexOf("\\"));
//            } else if (filePath.lastIndexOf("//") > 0) {
//                name = filePath.substring(filePath.lastIndexOf("//"));
//            } else {
//                throw new RuntimeException("固件路径错误:" + filePath);
//            }
            try {
                RgvFileSendSector.sendFile(fileInputStream, rgv, name);
            } finally {

            }
        }
    }

    /**
     * 心跳
     *
     * @param bs 发送内容
     * @return RES返回结果
     * @throws IOException 网络异常
     */
//    @RvgLog(value = "心跳", useMethod = false)
    public byte[] heartRequest(byte[] bs) throws IOException {
        long time = System.currentTimeMillis();
        byte recData[] = LongConnSendUtilLora.send(bs, rgv);
        rgv.setPing((int) (System.currentTimeMillis() - time));
        RgvLogRecorder.recordRgvHearLog(recData, rgv.getRgvName(), time, System.currentTimeMillis());
        return recData;
    }

    /**
     * 5.4TL心跳
     *
     * @return RES返回结果
     * @throws IOException 网络异常
     */
//    @RvgLog(value = "心跳", useMethod = false)
    public RgvBaseMessage heartRequest(RgvLifeSendMessage rgvLifeSendMessage) throws IOException {
        long time = System.currentTimeMillis();
        RgvBaseMessage rgvBaseMessage = rgv.getRgvProtocol().comm(rgvLifeSendMessage);
        RgvLogRecorder.recordRgvHearLog(rgvBaseMessage, rgv.getRgvName(), time, System.currentTimeMillis());
        return rgvBaseMessage;
    }

    /**
     * 发送完整节点
     *
     * @param taskNo
     * @param route
     */
    @RvgLog(value = "发送完整节点")
    public void wholeRouteSend(Integer wcsTaskNo, Integer taskNo, Route route) {
        MoveOrder moveOrder = new MoveOrder(taskNo, ResTaskType.SEND_TASK.getCode(), route.getSegmentNum(), route.getNodeList());
        log.info("发送节点整体下发任务：" + moveOrder);
        rgv.setCurResTaskNo(taskNo);
        wholeRouteSendWithResult(wcsTaskNo, moveOrder);
    }

    /**
     * 发送行驶节点 不需要监控
     *
     * @param wcsTaskNo
     * @param nodeToRes
     * @param moveNo
     */
    @RvgLog(value = "发送行驶节点")
    public void run(Integer wcsTaskNo, NodeToRes nodeToRes, Integer moveNo) {
        if (rgv.checkRgvType(RgvType.RGV_SEER_COMM)) {
            Rgv60  rgv60 = (Rgv60) rgv;
            List<Node> nodes = new ArrayList<>();
            nodes.add(nodeToRes.getNode());
            rgv60.getRgvCore().task(moveNo, nodes);
            return;
        }

        if (RgvType.FOUR_GENERATIONS.getValue() == rgv.getRgvDB().getRgvType()) {
            MoveOrder moveOrder = new MoveOrder(moveNo, ResTaskType.RUN.getCode(), nodeToRes.getCurSegmentNum());
            run(wcsTaskNo, moveOrder);
        } else if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
            LoggerUtil.info(rgv.getRgvName() + "发送行驶命令：" + nodeToRes.getCurSegmentNum(), this.getClass());
            int cmdNo = getAutoIncrementCmdNum();
            senCmd(new CmdSendBeanV3(rgvNo, moveNo, cmdNo, Order.SEND_SEGMENT_NO.getOrderByte(), nodeToRes.getCurSegmentNum()));
        }

    }

    private void run(Integer wcsTaskNo, MoveOrder moveOrder) {
        boolean retryFlag = true;
        while (retryFlag) {
            log.info("发送行驶命令:" + moveOrder);
            long sendTime = System.currentTimeMillis();
            rgv.getRgvHeart().getMoveCommand().add(moveOrder);
            try {
                WcsHeartThread.doExec(ToRes.getInstance(rgv).heartRequest(ByteBeanUtil.toByte(rgv.getRgvHeart(), rgv.getRgvDB().getRgvNo())));
                rgv.checkInterrupt("ToResRun", sendTime);
                if (!resReceiveResult(wcsTaskNo, moveOrder, sendTime)) {
                    continue;
                }
                retryFlag = false;
            } catch (IOException e) {
                log.error(rgv.getRgvName() + "通讯失败");
            }
        }
    }

    /**
     * 托盘取货
     */
    @RvgLog(value = "托盘取货")
    public void palletUp(Integer wcsTaskNo) {
        if (rgv.checkRgvType(RgvType.RGV_SEER_COMM)) {
            ((Rgv60) rgv).getRgvCore().action(Order.PALLET_UP);
        } else {
            long sendTime = System.currentTimeMillis();
            actionHandle(wcsTaskNo, Order.PALLET_UP);
            while (rgv.getPalletStatus() != PalletStatus.UP) {
                rgv.checkInterrupt("WAIT_PALLET_UP", sendTime);
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    /**
     * 滚筒开始加载
     */
    @RvgLog(value = "滚筒开始加载")
    public void rollerRun(int param) {
        if (rgv.checkRgvType(RgvType.RGV_ROLLER)) {
            ((Rgv60) rgv).getRgvCore().action(Order.PALLET_UP, param);
        }
    }

    /**
     * 等待托盘取货完成
     */
//    @RvgLog(value = "托盘取货")
    public void waitHasCargo() {
        if (rgv.checkRgvType(RgvType.RGV_ROLLER)) {
            ((Rgv60) rgv).getRgvCore().action(Order.WAIT_HAS_CARGO, 0);
        }
    }

    /**
     * 等待托盘放货完成
     */
//    @RvgLog(value = "托盘取货")
    public void waitNoCargo() {
        if (rgv.checkRgvType(RgvType.RGV_ROLLER)) {
            ((Rgv60) rgv).getRgvCore().action(Order.WAIT_NO_CARGO, 0);
        }
    }

    /**
     * 停止滚动
     */
//    @RvgLog(value = "托盘取货")
    public void stopRoller() {
        if (rgv.checkRgvType(RgvType.RGV_ROLLER)) {
            ((Rgv60) rgv).getRgvCore().action(Order.ROLLER_STOP, 3);
        }
    }

    /**
     * 托盘放货
     */
    @RvgLog(value = "托盘放货")
    public void palletDown(Integer wcsTaskNo) {
        if (rgv.checkRgvType(RgvType.RGV_SEER_COMM)) {
            ((Rgv60) rgv).getRgvCore().action(Order.PALLET_DOWN);
        } else {
            long sendTime = System.currentTimeMillis();
            actionHandle(wcsTaskNo, Order.PALLET_DOWN);
            while (rgv.getPalletStatus() != PalletStatus.DOWN) {
                rgv.checkInterrupt("WAIT_PALLET_DOWN", sendTime);
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    /**
     * 托盘放货
     */
    @RvgLog(value = "托盘放货")
    public void rollerDown(int param) {
        if (rgv.checkRgvType(RgvType.RGV_ROLLER)) {
            ((Rgv60) rgv).getRgvCore().action(Order.PALLET_DOWN, param);
        } else {
            throw new RuntimeException("只有滚筒车支持 rollerDown");
        }
    }

    /**
     * 小车休眠
     */
    @RvgLog(value = "小车休眠")
    public void shutDown(Integer wcsTaskNo) {
        actionHandle(wcsTaskNo, Order.RGV_SHUT_DOWN);
    }

    /**
     * 小车唤醒
     */
    @RvgLog(value = "小车唤醒")
    public void wakeUp(Integer wcsTaskNo) {
        actionHandle(wcsTaskNo, Order.RGV_RESTART);
    }

    /**
     * 开始充电
     */
    @RvgLog(value = "开始充电")
    public void openCharge(Integer wcsTaskNo) {
        if (rgv.checkRgvType(RgvType.RGV_SON_MOTHER)) {
            ((RgvSM) rgv).getRgvCore().action(Order.START_CHARGE);
        } else {
            actionHandle(wcsTaskNo, Order.START_CHARGE);
        }
    }

    /**
     * 关闭充电
     */
    @RvgLog(value = "关闭充电")
    public synchronized void closeCharge(Integer wcsTaskNo) {
        if (rgv.checkRgvType(RgvType.RGV_SON_MOTHER)) {
            ((RgvSM) rgv).getRgvCore().action(Order.CLOSE_CHARGE);
        } else {
            actionHandle(wcsTaskNo, Order.CLOSE_CHARGE);
        }
    }

    /**
     * 换向坡道
     */
    @RvgLog(value = "换向坡道")
    public void changeToRamp(Integer wcsTaskNo) {
        actionHandle(wcsTaskNo, Order.CHANGE_TO_RAMP);
    }

    /**
     * 换向巷道
     */
    @RvgLog(value = "换向巷道")
    public void changeToRoadway(Integer wcsTaskNo) {
        actionHandle(wcsTaskNo, Order.CHANGE_TO_ROADWAY);
    }

    /**
     * 按速度行驶停
     */
    @RvgLog(value = "按速度行驶停")
    public void stopWithSpeed(Integer wcsTaskNo) {
        actionHandle(wcsTaskNo, Order.STOP_WITH_SPEED);
    }

    /**
     * 托盘校准
     */
    @RvgLog(value = "托盘校准")
    public void calibrationPallet(Integer wcsTaskNo) {
        if (rgv.checkRgvType(RgvType.RGV_SEER_COMM)) {
            ((Rgv60) rgv).getRgvCore().action(Order.MANUAL_CALIBRATION);
        } else {
            actionHandle(wcsTaskNo, Order.CALIBRATION_PALLET);
        }
    }


    /**
     * 托盘校准+顶升
     */
    @RvgLog(value = "托盘校准+顶升")
    public void calibrationPalletUp(Integer wcsTaskNo) {
        actionHandle(wcsTaskNo, Order.CALIBRATION_PALLET_UP);
    }
    /**
     * 手动校准
     * 参数默认给50
     */
    @RvgLog(value = "手动校准")
    public void manualCalibration(Integer wcsTaskNo) {
        if (rgv.checkRgvType(RgvType.RGV_SEER_COMM)) {
            ((Rgv60) rgv).getRgvCore().action(Order.MANUAL_CALIBRATION);
        } else {
            actionHandle(wcsTaskNo, Order.MANUAL_CALIBRATION, 50);
        }
    }

    /**
     * 发送地图
     */
    @RvgLog(value = "发送地图")
    public void sendMap(Integer wcsTaskNo) {
        if (RgvType.FOUR_GENERATIONS.getValue() == rgv.getRgvDB().getRgvType()) {
            actionHandle(wcsTaskNo, Order.SEND_MAP);
        } else if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
            actionHandle(wcsTaskNo, Order.SEND_MAP);
        }

    }

    /**
     * 校准位置并验证条码
     */
    @RvgLog(value = "校准位置并验证条码")
    public void calibrationNode() {
        if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)
                || RgvType.FOUR_GENERATIONS.getValue() == rgv.getRgvDB().getRgvType()) {
            actionHandle(null, Order.CALIBRATION_NODE,Integer.valueOf(rgv.getGroundCode()));
        }
    }

    /**
     * 更新行驶固件
     * @param wcsTaskNo
     */
    @RvgLog(value = "更新行驶固件")
    public void sendDriverFirmware(Integer wcsTaskNo) {
        if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
            actionHandle(wcsTaskNo, Order.UPDATE_DRIVER_FIRMWARE);
        }
    }

    /**
     * 更新oil固件
     * @param wcsTaskNo
     */
    @RvgLog(value = "更新oil固件")
    public void sendOilPumpFirmware(Integer wcsTaskNo) {
        if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
            actionHandle(wcsTaskNo, Order.UPDATE_OIL_PUMP_FIRMWARE);
        }
    }

    /**
     * 更新res固件
     * @param wcsTaskNo
     */
    @RvgLog(value = "更新res固件")
    public void sendResFirmware(Integer wcsTaskNo) {
        if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
            actionHandle(wcsTaskNo, Order.UPDATE_RES_FIRMWARE);
        }
    }

    /**
     * 提取WCS日志
     * @param wcsTaskNo
     */
    @RvgLog(value = "提取WCS日志")
    public void sendExtractWcsLog(Integer wcsTaskNo) {
        if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
            actionHandle(wcsTaskNo, Order.EXTRACT_WCS_LOG);
        }
    }

    /**
     * 提取KCS日志
     * @param wcsTaskNo
     */
    @RvgLog(value = "提取KCS日志")
    public void sendExtractKcsLog(Integer wcsTaskNo) {
        if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
            actionHandle(wcsTaskNo, Order.EXTRACT_KCS_LOG);
        }
    }

    /**
     * 提取油泵日志
     * @param wcsTaskNo
     */
    @RvgLog(value = "提取油泵日志")
    public void sendExtractOilPumpLog(Integer wcsTaskNo) {
        if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
            actionHandle(wcsTaskNo, Order.EXTRACT_OIL_PUMP_LOG);
        }
    }

    /**
     * 提取行驶日志
     * @param wcsTaskNo
     */
    @RvgLog(value = "提取行驶日志")
    public void sendExtractDriverLog(Integer wcsTaskNo) {
        if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
            actionHandle(wcsTaskNo, Order.EXTRACT_DRIVER_LOG);
        }
    }

    /**
     * 提取WCS备份日志
     * @param wcsTaskNo
     */
    @RvgLog(value = "提取WCS备份日志")
    public void sendExtractWcsBackUpLog(Integer wcsTaskNo) {
        if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
            actionHandle(wcsTaskNo, Order.EXTRACT_WCS_BACK_UP_LOG);
        }
    }

    /**
     * 提取KCS备份日志
     * @param wcsTaskNo
     */
    @RvgLog(value = "提取KCS备份日志")
    public void sendExtractKcsBackUpLog(Integer wcsTaskNo) {
        if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
            actionHandle(wcsTaskNo, Order.EXTRACT_KCS_BACK_UP_LOG);
        }
    }

    /**
     * 提取油泵备份日志
     * @param wcsTaskNo
     */
    @RvgLog(value = "提取油泵备份日志")
    public void sendExtractOilPumpBackUpLog(Integer wcsTaskNo) {
        if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
            actionHandle(wcsTaskNo, Order.EXTRACT_OIL_PUMP_BACK_UP_LOG);
        }
    }

    /**
     * 提取行驶备份日志
     * @param wcsTaskNo
     */
    @RvgLog(value = "提取行驶备份日志")
    public void sendExtractDriverBackUpLog(Integer wcsTaskNo) {
        if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
            actionHandle(wcsTaskNo, Order.EXTRACT_DRIVER_BACK_UP_LOG);
        }
    }

    /**
     * 按距离&方向行驶
     */
    @RvgLog(value = "按距离&方向行驶")
    public void runWithDstance(Integer wcsTaskNo, Integer direction, Integer distance) {
        switch (direction) {
            case 1:
                actionHandle(wcsTaskNo, Order.RUN_WITH_DISTANCE_ONE, distance);
                break;
            case 2:
                actionHandle(wcsTaskNo, Order.RUN_WITH_DISTANCE_TWO, distance);
                break;
            case 3:
                actionHandle(wcsTaskNo, Order.RUN_WITH_DISTANCE_THREE, distance);
                break;
            case 4:
                actionHandle(wcsTaskNo, Order.RUN_WITH_DISTANCE_FOUR, distance);
                break;
            default:
                throw new IllegalArgumentException("参数非法");
        }
    }

    /**
     * 按距离&方向长感应停
     */
    @RvgLog(value = "按距离&方向长感应停")
    public void stopWithDstance(Integer wcsTaskNo, Integer direction, Integer distance) {
        switch (direction) {
            case 1:
                actionHandle(wcsTaskNo, Order.STOP_WITH_DISTANCE_ONE, distance);
                break;
            case 2:
                actionHandle(wcsTaskNo, Order.STOP_WITH_DISTANCE_TWO, distance);
                break;
            case 3:
                actionHandle(wcsTaskNo, Order.STOP_WITH_DISTANCE_THREE, distance);
                break;
            case 4:
                actionHandle(wcsTaskNo, Order.STOP_WITH_DISTANCE_FOUR, distance);
                break;
            default:
                throw new IllegalArgumentException("参数非法");
        }
    }

    /**
     * 同步时间
     */
    @RvgLog(value = "同步时间")
    public void syncTime(Integer wcsTaskNo) {
        if (rgv.checkRgvType(RgvType.RGV_SEER_COMM)) {
            return;
        }

        actionHandle(wcsTaskNo, Order.SYNC_TIME, (int) (System.currentTimeMillis() / (long) 1000));
    }

    /**
     * 更新坐标
     */
    @RvgLog(value = "更新坐标")
    public void changeLocation(Integer wcsTaskNo, Coord location) {
        if (rgv.checkRgvType(RgvType.RGV_SEER_COMM)) {
            ((Rgv60) rgv).getRgvCore().action(
                    Order.CHANGE_MAP, location.getZ());
            ((Rgv60) rgv).analyzeData();
        }  else {
            long sendTime = System.currentTimeMillis();
            Order changeLocation = Order.CHANGE_LOCATION;
            int nodeInt = MsgTransferUtil.parseLocation(location.getX(), location.getY(), location.getZ());
            actionHandle(wcsTaskNo, changeLocation, nodeInt);
            while (!location.equals(rgv.getCurLocation())) {
                rgv.checkInterrupt("WAIT_CHANGE_LOCATION", sendTime);
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    /**
     * 紧急停止
     */
    @RvgLog(value = "紧急停止")
    public void emergencyStop(Integer wcsTaskNo) {
        actionHandle(wcsTaskNo, Order.EMERGENCY_STOP);
    }

    /**
     * 设置小车正常行驶速度
     */
    @RvgLog(value = "设置小车正常行驶速度")
    public void setSpeed(Integer wcsTaskNo, Integer speed) {
        Order changeSpeed = Order.CHANGE_SPEED;
        actionHandle(wcsTaskNo, changeSpeed, speed);
    }

    /**
     * 设置小车特殊位置行驶速度
     */
    @RvgLog(value = "设置小车特殊位置行驶速度")
    public void setSpecialSpeed(Integer wcsTaskNo, Integer speed) {
        Order specialLocation = Order.CHANGE_SPECIAL_SPEED;
        actionHandle(wcsTaskNo, specialLocation, speed);
    }

    /**
     * WCS刚启动时，会给小车下发初始化指令，清空小车的任务
     */
    @RvgLog(value = "初始化")
    public void initialize(Integer wcsTaskNo) {
        if (rgv.checkRgvType(RgvType.RGV_SEER_COMM)) {
            ((Rgv60) rgv).getRgvCore().action(Order.INITIALIZE, rgv.getRgvDB().getRgvIp());
        } else {
            Order initialize = Order.INITIALIZE;
            actionHandle(wcsTaskNo, initialize);

            if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
                rgv.getTaskAction().initStatus();
            }
        }
    }

    /**
     * 驱动器故障恢复
     */
    @RvgLog(value = "驱动器故障恢复")
    public void recoveryDriverError(Integer wcsTaskNo) {
        //清除换向驱动器故障
        Order order = Order.CLEAR_ERROR_DIRECT_DRIVER;
        actionHandle(wcsTaskNo, order);

        //清除行驶驱动器故障
        order = Order.CLEAR_ERROR_DRIVER;
        actionHandle(wcsTaskNo, order);
    }

    /**
     * 取消任务
     */
    @RvgLog(value = "取消任务")
    public void cancel(Integer wcsTaskNo) {
        actionHandle(wcsTaskNo, Order.CANCEL);
    }

    /**
     * 查询小车上方是否有货
     */
    @RvgLog(value = "查询小车上方是否有货")
    public void checkPallet(Integer wcsTaskNo) {
        actionHandle(wcsTaskNo, Order.CHECK_PALLET);
    }

    /**
     * 发送提升机所在层
     */
    @RvgLog(value = "发送提升机所在层")
    public void liftCurLayer(Integer wcsTaskNo, int layer) {
        Order curLiftLayer = Order.CUR_LIFT_LAYER;
        actionHandle(wcsTaskNo, curLiftLayer, layer);
    }

    /**
     * 暂停行驶
     */
    @RvgLog(value = "暂停行驶")
    public void pauseRun(Integer wcsTaskNo) {
        actionHandle(wcsTaskNo, Order.PAUSE_RUN);
    }

    /**
     * 暂停恢复
     */
    @RvgLog(value = "暂停恢复")
    public void pauseRecover(Integer wcsTaskNo) {
        actionHandle(wcsTaskNo, Order.PAUSE_RECOVER);
    }

    /**
     * 打开蜂鸣器
     */
    @RvgLog(value = "打开蜂鸣器")
    public void openAlarm(Integer wcsTaskNo) {
        actionHandle(wcsTaskNo, Order.OPEN_ALARM);
    }

    /**
     * 关闭蜂鸣器
     */
    @RvgLog(value = "关闭蜂鸣器")
    public void closeAlarm(Integer wcsTaskNo) {
        actionHandle(wcsTaskNo, Order.CLOSE_ALARM);
    }

    /**
     * 发送换向巷道
     */
    @RvgLog(value = "发送换向巷道")
    public void switchHD(Integer wcsTaskNo) {
        actionHandle(wcsTaskNo, Order.CHANGE_TO_ROADWAY);
    }

    /**
     * 发送换向坡道
     */
    @RvgLog(value = "发送换向坡道")
    public void switchPD(Integer wcsTaskNo) {
        actionHandle(wcsTaskNo, Order.CHANGE_TO_RAMP);
    }

    /**
     * 获取电池电量
     */
    @RvgLog(value = "电池电量")
    public int getBattery(Integer wcsTaskNo) {
        int actionNo = getAutoIncrementCmdNum();
        CmdSendBeanV3 cmdSendBeanV3 = new CmdSendBeanV3(rgvNo, actionNo, Order.BATTERY_LEVEL.getOrderByte());
//        log.info(rgv.getRgvName() + "获取电量: " + cmdSendBeanV3);
        return senCmd(cmdSendBeanV3);
    }

    /**
     * 获取校准时间
     */
    @RvgLog(value = "获取校准时间")
    public int getCalibrationTime(Integer wcsTaskNo) {
        int actionNo = getAutoIncrementCmdNum();
        CmdSendBeanV3 cmdSendBeanV3 = new CmdSendBeanV3(rgvNo, actionNo,
                Order.GET_CALIBRATION_GROUNDCODE_TIME.getOrderByte());
        log.info(rgv.getRgvName() + "发送获取校准时间指令" + cmdSendBeanV3);
        return senCmd(cmdSendBeanV3);
    }

    /**
     * 按速度&方向行驶
     */
    @RvgLog(value = "按速度&方向行驶")
    public void runWithSpeed(Integer wcsTaskNo, Integer direction, Integer speed) {
        switch (direction) {
            case 1:
                actionHandle(wcsTaskNo, Order.RUN_WITH_SPEED_ONE, speed);
                break;
            case 2:
                actionHandle(wcsTaskNo, Order.RUN_WITH_SPEED_TWO, speed);
                break;
            case 3:
                actionHandle(wcsTaskNo, Order.RUN_WITH_SPEED_THREE, speed);
                break;
            case 4:
                actionHandle(wcsTaskNo, Order.RUN_WITH_SPEED_FOUR, speed);
                break;
            default:
                throw new IllegalArgumentException("参数非法");
        }
    }

    /**
     * 设置最大速度
     */
    @RvgLog(value = "设置最大速度")
    public void setMaxSpeed(Integer wcsTaskNo, Integer maxSpeed) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setMaxSpeed = SeconOrder.MAX_SPEED;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setMaxSpeed, maxSpeed);
    }

    /**
     * 设置加速度
     */
    @RvgLog(value = "设置加速度")
    public void setAcceleration(Integer wcsTaskNo, Integer acceleration) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setAcceleration = SeconOrder.ACCELERATION;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setAcceleration, acceleration);
    }

    /**
     * 设置减速度
     */
    @RvgLog(value = "设置减速度")
    public void setDeceleration(Integer wcsTaskNo, Integer deceleration) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setDeceleration = SeconOrder.DECELERATION;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setDeceleration, deceleration);
    }

    /**
     * 设置校准速度
     */
    @RvgLog(value = "设置校准速度")
    public void setCorrSpeed(Integer wcsTaskNo, Integer corrSpeed) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setCorrSpeed = SeconOrder.CORR_SPEED;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setCorrSpeed, corrSpeed);
    }

    /**
     * 设置校准超时时间
     */
    @RvgLog(value = "设置校准超时时间")
    public void setCorrOvertime(Integer wcsTaskNo, Integer corrOvertime) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setCorrOvertime = SeconOrder.CORR_OVERTIME;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setCorrOvertime, corrOvertime);
    }

    /**
     * 设置倍加福联系条码坡道K值
     */
    @RvgLog(value = "设置倍加福联系条码坡道K值")
    public void setBeijiaBarRamp(Integer wcsTaskNo, Integer beijiaBarRamp) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setBeijiaBarRamp = SeconOrder.BEIJIA_BAR_RAMP;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setBeijiaBarRamp, beijiaBarRamp);
    }

    /**
     * 设置倍加福联系条码巷道K值
     */
    @RvgLog(value = "设置倍加福联系条码巷道K值")
    public void setBeijiaBarRoadway(Integer wcsTaskNo, Integer beijiaBarRoadway) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setBeijiaBarRoadway = SeconOrder.BEIJIA_BAR_ROADWAY;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setBeijiaBarRoadway, beijiaBarRoadway);
    }

    /**
     * 设置内部功能开关
     */
    @RvgLog(value = "设置内部功能开关")
    public void setInternalFunction(Integer wcsTaskNo, Integer internalFunction) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setInternalFunction = SeconOrder.INTERNAL_FUNCTION;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setInternalFunction, internalFunction);
    }

    /**
     * 设置根据换向次数重启功能
     */
    @RvgLog(value = "设置根据换向次数重启功能")
    public void setCommutationRestart(Integer wcsTaskNo, Integer commutationRestart) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setCommutationRestart = SeconOrder.COMMUTATION_RESTART;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setCommutationRestart, commutationRestart);
    }

    /**
     * 设置车体类型
     */
    @RvgLog(value = "设置车体类型")
    public void setVehicleType(Integer wcsTaskNo, Integer vehicleType) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setVehicleType = SeconOrder.VEHICLE_TYPE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setVehicleType, vehicleType);
    }

    /**
     * 设置扫码器类型
     */
    @RvgLog(value = "设置扫码器类型")
    public void setScanType(Integer wcsTaskNo, Integer scanType) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setScanType = SeconOrder.SCAN_TYPE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setScanType, scanType);
    }

    /**
     * 设置激光雷达最小阈值判断
     */
    @RvgLog(value = "设置激光雷达最小阈值判断")
    public void setMinRadar(Integer wcsTaskNo, Integer minRadar) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setMinRadar = SeconOrder.MIN_RADAR;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setMinRadar, minRadar);
    }

    /**
     * 设置激光雷达最大阈值判断
     */
    @RvgLog(value = "设置激光雷达最大阈值判断")
    public void setMaxRadar(Integer wcsTaskNo, Integer maxRadar) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setMaxRadar = SeconOrder.MAX_RADAR;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setMaxRadar, maxRadar);
    }

    /**
     * 设置关闭雷达剩余距离
     */
    @RvgLog(value = "设置关闭雷达剩余距离")
    public void setCloseResidualRange(Integer wcsTaskNo, Integer closeResidualRange) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setCloseResidualRange = SeconOrder.CLOSE_RESIDUAL_RANGE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setCloseResidualRange, closeResidualRange);
    }

    /**
     * 设置雷达感应停止距离
     */
    @RvgLog(value = "设置雷达感应停止距离")
    public void setRadarStopDistance(Integer wcsTaskNo, Integer radarStopDistance) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setRadarStopDistance = SeconOrder.RADAR_STOP_DISTANCE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setRadarStopDistance, radarStopDistance);
    }

    /**
     * 设置打开看门狗功能
     */
    @RvgLog(value = "设置打开看门狗功能")
    public void setOpenWatchdog(Integer wcsTaskNo, Integer openWatchdog) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setOpenWatchdog = SeconOrder.OPEN_WATCHDOG;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setOpenWatchdog, openWatchdog);
    }

    /**
     * 设置激光雷达个数
     */
    @RvgLog(value = "设置激光雷达个数")
    public void setRadarNum(Integer wcsTaskNo, Integer radarNum) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setRadarNum = SeconOrder.RADAR_NUM;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setRadarNum, radarNum);
    }

    /**
     * 设置elmo驱动器通讯波特率
     */
    @RvgLog(value = "设置elmo驱动器通讯波特率")
    public void setElmoBaudRate(Integer wcsTaskNo, Integer elmoBaudRate) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setElmoBaudRate = SeconOrder.ELMO_BAUD_RATE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setElmoBaudRate, elmoBaudRate);
    }

    /**
     * 设置控制板类型
     */
    @RvgLog(value = "设置控制板类型")
    public void setControlBoardType(Integer wcsTaskNo, Integer controlBoardType) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setControlBoardType = SeconOrder.CONTROL_BOARD_TYPE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setControlBoardType, controlBoardType);
    }

    /**
     * 设置货位校准光电极性
     */
    @RvgLog(value = "设置货位校准光电极性")
    public void setLocationCalibration(Integer wcsTaskNo, Integer locationCalibration) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setLocationCalibration = SeconOrder.LOCATION_CALIBRATION;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setLocationCalibration, locationCalibration);
    }

    /**
     * 设置巷道民德扫码校准正负偏差
     */
    @RvgLog(value = "设置巷道民德扫码校准正负偏差")
    public void setMindeRoadwayDiff(Integer wcsTaskNo, Integer mindeRoadwayDiff) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setMindeRoadwayDiff = SeconOrder.MINDE_ROADWAY_DIFF;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setMindeRoadwayDiff, mindeRoadwayDiff);
    }

    /**
     * 设置坡道民德扫码校准正负偏差
     */
    @RvgLog(value = "设置坡道民德扫码校准正负偏差")
    public void setMindeRampDiff(Integer wcsTaskNo, Integer mindeRampDiff) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setMindeRampDiff = SeconOrder.MINDE_RAMP_DIFF;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setMindeRampDiff, mindeRampDiff);
    }

    /**
     * 设置巷道民德扫码校准目标像素
     */
    @RvgLog(value = "设置巷道民德扫码校准目标像素")
    public void setMindeRoadwayTargetPx(Integer wcsTaskNo, Integer mindeRoadwayTargetPx) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setMindeRoadwayTargetPx = SeconOrder.MINDE_ROADWAY_TARGET_PX;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setMindeRoadwayTargetPx, mindeRoadwayTargetPx);
    }

    /**
     * 设置坡道民德扫码校准目标像素
     */
    @RvgLog(value = "设置坡道民德扫码校准目标像素")
    public void setMindeRampTargetPx(Integer wcsTaskNo, Integer mindeRampTargetPx) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setMindeRampTargetPx = SeconOrder.MINDE_RAMP_TARGET_PX;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setMindeRampTargetPx, mindeRampTargetPx);
    }

    /**
     * 设置巷道民德扫码减速像素
     */
    @RvgLog(value = "设置巷道民德扫码减速像素")
    public void setMindeRoadwayDecePx(Integer wcsTaskNo, Integer mindeRoadwayDecePx) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setMindeRoadwayDecePx = SeconOrder.MINDE_ROADWAY_DECE_PX;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setMindeRoadwayDecePx, mindeRoadwayDecePx);
    }

    /**
     * 设置坡道民德扫码减速像素
     */
    @RvgLog(value = "设置坡道民德扫码减速像素")
    public void setMindeRampDecePx(Integer wcsTaskNo, Integer mindeRampDecePx) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setMindeRampDecePx = SeconOrder.MINDE_RAMP_DECE_PX;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setMindeRampDecePx, mindeRampDecePx);
    }

    /**
     * 设置托盘校准类型
     */
    @RvgLog(value = "设置托盘校准类型")
    public void setPalletCalibrationType(Integer wcsTaskNo, Integer palletCalibrationType) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setPalletCalibrationType = SeconOrder.PALLET_CALIBRATION_TYPE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setPalletCalibrationType, palletCalibrationType);
    }

    /**
     * 设置民德托盘一方向目标像素
     */
    @RvgLog(value = "设置民德托盘一方向目标像素")
    public void setMindePalletOneDir(Integer wcsTaskNo, Integer mindePalletOneDir) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setMindePalletOneDir = SeconOrder.MINDE_PALLET_ONE_DIR;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setMindePalletOneDir, mindePalletOneDir);
    }

    /**
     * 设置民德托盘三方向目标像素
     */
    @RvgLog(value = "设置民德托盘三方向目标像素")
    public void setMindePalletThreeDir(Integer wcsTaskNo, Integer mindePalletThreeDir) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setMindePalletThreeDir = SeconOrder.MINDE_PALLET_THREE_DIR;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setMindePalletThreeDir, mindePalletThreeDir);
    }

    /**
     * 设置民德托盘左偏移像素
     */
    @RvgLog(value = "设置民德托盘左偏移像素")
    public void setMindePalletLeft(Integer wcsTaskNo, Integer mindePalletLeft) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setMindePalletLeft = SeconOrder.MINDE_PALLET_LEFT;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setMindePalletLeft, mindePalletLeft);
    }

    /**
     * 设置民德托盘右偏移像素
     */
    @RvgLog(value = "设置民德托盘右偏移像素")
    public void setMindePalletRight(Integer wcsTaskNo, Integer mindePalletRight) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setMindePalletRight = SeconOrder.MINDE_PALLET_RIGHT;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setMindePalletRight, mindePalletRight);
    }

    /**
     * 设置新大陆条码位数
     */
    @RvgLog(value = "设置新大陆条码位数")
    public void setXindaBar(Integer wcsTaskNo, Integer xindaBar) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setXindaBar = SeconOrder.XINDA_BAR;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setXindaBar, xindaBar);
    }

    /**
     * 设置民德扫码器的二次校准正负偏差
     */
    @RvgLog(value = "设置民德扫码器的二次校准正负偏差")
    public void setMindeTwotime(Integer wcsTaskNo, Integer mindeTwotime) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setMindeTwotime = SeconOrder.MINDE_TWOTIME;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setMindeTwotime, mindeTwotime);
    }

    /**
     * 设置海康威视扫码器的校准正负偏差
     */
    @RvgLog(value = "设置海康威视扫码器的校准正负偏差")
    public void setHkDiff(Integer wcsTaskNo, Integer hkDiff) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setHkDiff = SeconOrder.HK_DIFF;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setHkDiff, hkDiff);
    }

    /**
     * 设置倍加福扫码器的校准正负偏差
     */
    @RvgLog(value = "设置倍加福扫码器的校准正负偏差")
    public void setBeijiaDiff(Integer wcsTaskNo, Integer beijiaDiff) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setBeijiaDiff = SeconOrder.BEIJIA_DIFF;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setBeijiaDiff, beijiaDiff);
    }

    /**
     * 设置托盘扫码器的校准正负偏差
     */
    @RvgLog(value = "设置托盘扫码器的校准正负偏差")
    public void setPalletDiff(Integer wcsTaskNo, Integer palletDiff) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setPalletDiff = SeconOrder.PALLET_DIFF;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setPalletDiff, palletDiff);
    }

    /**
     * 设置第一次遇到障碍物停止的减速度
     */
    @RvgLog(value = "设置第一次遇到障碍物停止的减速度")
    public void setOnetimeDece(Integer wcsTaskNo, Integer onetimeDece) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setOnetimeDece = SeconOrder.ONETIME_DECE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setOnetimeDece, onetimeDece);
    }

    /**
     * 设置临时暂停时间
     */
    @RvgLog(value = "设置临时暂停时间")
    public void setTemporaryPauseTime(Integer wcsTaskNo, Integer temporaryPauseTime) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setTemporaryPauseTime = SeconOrder.TEMPORARY_PAUSE_TIME;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setTemporaryPauseTime, temporaryPauseTime);
    }

    /**
     * 设置蠕行阶段行驶速度
     */
    @RvgLog(value = "设置蠕行阶段行驶速度")
    public void setSlowSpeed(Integer wcsTaskNo, Integer slowSpeed) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setSlowSpeed = SeconOrder.SLOW_SPEED;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setSlowSpeed, slowSpeed);
    }

    /**
     * 设置托盘的雷达的位移比例
     */
    @RvgLog(value = "设置托盘的雷达的位移比例")
    public void setRadarDisplace(Integer wcsTaskNo, Integer radarDisplace) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setRadarDisplace = SeconOrder.RADAR_DISPLACE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setRadarDisplace, radarDisplace);
    }

    /**
     * 设置第一次托盘感应停止距离
     */
    @RvgLog(value = "设置第一次托盘感应停止距离")
    public void setFirstStop(Integer wcsTaskNo, Integer firstStop) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setFirstStop = SeconOrder.FIRST_STOP;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setFirstStop, firstStop);
    }

    /**
     * 设置托盘最终停止的距离，上报暂停
     */
    @RvgLog(value = "设置托盘最终停止的距离，上报暂停")
    public void setLastStop(Integer wcsTaskNo, Integer lastStop) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setLastStop = SeconOrder.LAST_STOP;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setLastStop, lastStop);
    }

    /**
     * 设置蠕行阶段行驶时托盘激光雷达的波动范围
     */
    @RvgLog(value = "设置蠕行阶段行驶时托盘激光雷达的波动范围")
    public void setSlowMoveRadar(Integer wcsTaskNo, Integer slowMoveRadar) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setSlowMoveRadar = SeconOrder.SLOW_MOVE_RADAR;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setSlowMoveRadar, slowMoveRadar);
    }

    /**
     * 设置托盘激光连续N次的触发
     */
    @RvgLog(value = "设置托盘激光连续N次的触发")
    public void setPalletTrigger(Integer wcsTaskNo, Integer palletTrigger) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setPalletTrigger = SeconOrder.PALLET_TRIGGER;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setPalletTrigger, palletTrigger);
    }

    /**
     * 设置四周障碍物位移和速度比例
     */
    @RvgLog(value = "设置四周障碍物位移和速度比例")
    public void setDisplacementVelocityRatio(Integer wcsTaskNo, Integer displacementVelocityRatio) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setDisplacementVelocityRatio = SeconOrder.DISPLACEMENT_VELOCITY_RATIO;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setDisplacementVelocityRatio, displacementVelocityRatio);
    }

    /**
     * 设置四周障碍物感应的最远距离
     */
    @RvgLog(value = "设置四周障碍物感应的最远距离")
    public void setLongestDistance(Integer wcsTaskNo, Integer longestDistance) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setLongestDistance = SeconOrder.LONGEST_DISTANCE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setLongestDistance, longestDistance);
    }

    /**
     * 设置四周障碍物感应操作的最近距离
     */
    @RvgLog(value = "设置四周障碍物感应操作的最近距离")
    public void setNearesDistance(Integer wcsTaskNo, Integer nearesDistance) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setNearesDistance = SeconOrder.NEARES_DISTANCE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setNearesDistance, nearesDistance);
    }

    /**
     * 设置停下后四周障碍物激光雷达的波动范围
     */
    @RvgLog(value = "设置停下后四周障碍物激光雷达的波动范围")
    public void setStopAroundRadar(Integer wcsTaskNo, Integer stopAroundRadar) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setStopAroundRadar = SeconOrder.STOP_AROUND_RADAR;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setStopAroundRadar, stopAroundRadar);
    }

    /**
     * 设置蠕行阶段行驶时四周障碍物激光雷达的波动范围
     */
    @RvgLog(value = "设置蠕行阶段行驶时四周障碍物激光雷达的波动范围")
    public void setSlowAroundRadar(Integer wcsTaskNo, Integer slowAroundRadar) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setSlowAroundRadar = SeconOrder.SLOW_AROUND_RADAR;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setSlowAroundRadar, slowAroundRadar);
    }

    /**
     * 设置四周障碍物激光连续N次的触发
     */
    @RvgLog(value = "设置四周障碍物激光连续N次的触发")
    public void setAroundRadarTrigger(Integer wcsTaskNo, Integer aroundRadarTrigger) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setAroundRadarTrigger = SeconOrder.AROUND_RADAR_TRIGGER;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setAroundRadarTrigger, aroundRadarTrigger);
    }

    /**
     * 设置新益昌版本的默认加速度的加速度
     */
    @RvgLog(value = "设置新益昌版本的默认加速度的加速度")
    public void setXinyiAcc(Integer wcsTaskNo, Integer xinyiAcc) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setXinyiAcc = SeconOrder.XINYI_ACC;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setXinyiAcc, xinyiAcc);
    }

    /**
     * 设置新益昌驱动器重启时间
     */
    @RvgLog(value = "设置新益昌驱动器重启时间")
    public void setXinyiRestartTime(Integer wcsTaskNo, Integer xinyiRestartTime) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setXinyiRestartTime = SeconOrder.XINYI_RESTART_TIME;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setXinyiRestartTime, xinyiRestartTime);
    }

    /**
     * 设置停下后托盘激光雷达的波动范围
     */
    @RvgLog(value = "设置停下后托盘激光雷达的波动范围")
    public void setStopRadar(Integer wcsTaskNo, Integer stopRadar) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setStopRadar = SeconOrder.STOP_RADAR;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setStopRadar, stopRadar);
    }


    /**
     * 设置托盘校准速度
     */
    @RvgLog(value = "设置托盘校准速度")
    public void setPalletCalibrationSpeed(Integer wcsTaskNo, Integer palletCalibrationSpeed) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setPalletCalibrationSpeed = SeconOrder.PALLET_CALIBRATION_SPEED;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setPalletCalibrationSpeed, palletCalibrationSpeed);
    }

    /**
     * 设置一次托盘校准时间
     */
    @RvgLog(value = "设置一次托盘校准时间")
    public void setOnetimePalCaliTime(Integer wcsTaskNo, Integer onetimePalCaliTime) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setOnetimePalCaliTime = SeconOrder.ONETIME_PAL_CALI_TIME;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setOnetimePalCaliTime, onetimePalCaliTime);
    }

    /**
     * 设置托盘倾斜校准激光
     */
    @RvgLog(value = "设置托盘倾斜校准激光")
    public void setPalletJudgLaser(Integer wcsTaskNo, Integer palletJudgLaser) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setPalletJudgLaser = SeconOrder.PALLET_JUDG_LASER;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setPalletJudgLaser, palletJudgLaser);
    }

    /**
     * 设置心跳类型
     */
    @RvgLog(value = "设置心跳类型")
    public void setHeartType(Integer wcsTaskNo, Integer heartType) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setHeartType = SeconOrder.HEART_TYPE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setHeartType, heartType);
    }

    /**
     * 设置设备号
     */
    @RvgLog(value = "设置设备号")
    public void setDeviceNum(Integer wcsTaskNo, Integer deviceNum) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setDeviceNum = SeconOrder.DEVICE_NUM;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setDeviceNum, deviceNum);
    }

    /**
     * 设置RES校准方式
     */
    @RvgLog(value = "设置RES校准方式")
    public void setResCalib(Integer wcsTaskNo, Integer resCalib) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setResCalib = SeconOrder.RES_CALIB;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setResCalib, resCalib);
    }

    /**
     * 设置自动更新坐标开关
     */
    @RvgLog(value = "设置自动更新坐标开关")
    public void setAutoUpdae(Integer wcsTaskNo, Integer autoUpdae) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setAutoUpdae = SeconOrder.AUTO_UPDATE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setAutoUpdae, autoUpdae);
    }

    /**
     * 设置RES是否打印
     */
    @RvgLog(value = "设置RES是否打印")
    public void setResPrint(Integer wcsTaskNo, Integer resPrint) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setResPrint = SeconOrder.RES_PRINT;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setResPrint, resPrint);
    }

    /**
     * 设置RES变速行驶开关
     */
    @RvgLog(value = "设置RES变速行驶开关")
    public void setResDrivingSwitch(Integer wcsTaskNo, Integer resDrivingSwitch) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setResDrivingSwitch = SeconOrder.RES_DRIVING_SWITCH;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setResDrivingSwitch, resDrivingSwitch);
    }

    /**
     * 设置小车类型选择
     */
    @RvgLog(value = "设置小车类型选择")
    public void setTrolleyType(Integer wcsTaskNo, Integer trolleyType) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setTrolleyType = SeconOrder.TROLLEY_TYPE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setTrolleyType, trolleyType);
    }

    /**
     * 设置行驶心跳是否打印
     */
    @RvgLog(value = "设置行驶心跳是否打印")
    public void setHeartPrint(Integer wcsTaskNo, Integer heartPrint) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setHeartPrint = SeconOrder.HEART_PRINT;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setHeartPrint, heartPrint);
    }

    /**
     * 设置油泵心跳是否打印
     */
    @RvgLog(value = "设置油泵心跳是否打印")
    public void setPumpHeartPrint(Integer wcsTaskNo, Integer pumpHeartPrint) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setPumpheartPrint = SeconOrder.PUMP_HEART_PRINT;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setPumpheartPrint, pumpHeartPrint);
    }

    /**
     * 设置小车0x51指令下发的行驶速度
     */
    @RvgLog(value = "设置小车0x51指令下发的行驶速度")
    public void setDriSpeed(Integer wcsTaskNo, Integer driSpeed) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setDriSpeed = SeconOrder.DRI_SPEED;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setDriSpeed, driSpeed);
    }

    /**
     * 设置小车特殊位置的行驶速度
     */
    @RvgLog(value = "设置小车特殊位置的行驶速度")
    public void setSpeciDriSpeed(Integer wcsTaskNo, Integer speciDriSpeed) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setSpeciDriSpeed = SeconOrder.SPECI_DRI_SPEED;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setSpeciDriSpeed, speciDriSpeed);
    }

    /**
     * 设置报文版本
     */
    @RvgLog(value = "设置报文版本")
    public void setMessageVersion(Integer wcsTaskNo, Integer messageVersion) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setMessageVersion = SeconOrder.MESSAGE_VERSION;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setMessageVersion, messageVersion);
    }

    /**
     * 设置res往kcs发送报文重发次数
     */
    @RvgLog(value = "设置res往kcs发送报文重发次数")
    public void setRepeatTime(Integer wcsTaskNo, Integer repeatTime) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setRepeatTime = SeconOrder.REPEAT_TIME;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setRepeatTime, repeatTime);
    }

    /**
     * 设置底层串口类型
     */
    @RvgLog(value = "设置底层串口类型")
    public void setSerialPortType(Integer wcsTaskNo, Integer serialPortType) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setSerialPortType = SeconOrder.SERIAL_PORT_TYPE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setSerialPortType, serialPortType);
    }

    /**
     * 设置控制板类型
     */
    @RvgLog(value = "设置控制板类型")
    public void setContrBoardType(Integer wcsTaskNo, Integer contrBoardType) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setContrBoardType = SeconOrder.CONTR_BOARD_TYPE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setContrBoardType, contrBoardType);
    }

    /**
     * 设置地图申请空间X最大值
     */
    @RvgLog(value = "设置地图申请空间X最大值")
    public void setMapX(Integer wcsTaskNo, Integer mapX) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setMapX = SeconOrder.MAP_X;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setMapX, mapX);
    }

    /**
     * 设置地图申请空间Y最大值
     */
    @RvgLog(value = "设置地图申请空间Y最大值")
    public void setMapY(Integer wcsTaskNo, Integer mapY) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setMapY = SeconOrder.MAP_Y;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setMapY, mapY);
    }

    /**
     * 设置地图申请空间Z最大值
     */
    @RvgLog(value = "设置地图申请空间Z最大值")
    public void setMapZ(Integer wcsTaskNo, Integer mapZ) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setMapZ = SeconOrder.MAP_Z;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setMapZ, mapZ);
    }

    /**
     * 设置行驶指令使用接口0x51或者0x4f
     */
    @RvgLog(value = "设置行驶指令使用接口0x51或者0x4f")
    public void setDrivingCmd(Integer wcsTaskNo, Integer drivingCmd) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setDrivingCmd = SeconOrder.DRIVING_CMD;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setDrivingCmd, drivingCmd);
    }

    /**
     * 设置提升机无八码止退功能开关
     */
    @RvgLog(value = "设置提升机无八码止退功能开关")
    public void setLiftSwitch(Integer wcsTaskNo, Integer liftSwitch) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setLiftSwitch = SeconOrder.LIFT_SWITCH;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setLiftSwitch, liftSwitch);
    }

    /**
     * 设置小车故障状态开关
     */
    @RvgLog(value = "设置小车故障状态开关")
    public void setFaultSwitch(Integer wcsTaskNo, Integer faultSwitch) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setFaultSwitch = SeconOrder.FAULT_SWITCH;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setFaultSwitch, faultSwitch);
    }

    /**
     * 设置小车低电量自动休眠开关
     */
    @RvgLog(value = "设置小车低电量自动休眠开关")
    public void setLowBatterySwitch(Integer wcsTaskNo, Integer lowBatterySwitch) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setLowBatterySwitch = SeconOrder.LOW_BATTERY_SWITCH;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setLowBatterySwitch, lowBatterySwitch);
    }

    /**
     * 设置小车低电量自动休眠电量值
     */
    @RvgLog(value = "设置小车低电量自动休眠电量值")
    public void setLowBatteryValue(Integer wcsTaskNo, Integer lowBatteryValue) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setLowBatteryValue = SeconOrder.LOW_BATTERY_VALUE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setLowBatteryValue, lowBatteryValue);
    }

    /**
     * 设置换向巷道状态时，换向激光传感器1的默认数据
     */
    @RvgLog(value = "设置换向巷道状态时，换向激光传感器1的默认数据")
    public void setRoadwaySensorOne(Integer wcsTaskNo, Integer roadwaySensorOne) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setRoadwaySensorOne = SeconOrder.ROADWAY_SENSOR_ONE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setRoadwaySensorOne, roadwaySensorOne);
    }

    /**
     * 设置换向巷道状态时，换向激光传感器2的默认数据
     */
    @RvgLog(value = "设置换向巷道状态时，换向激光传感器2的默认数据")
    public void setRoadwaySensorTwo(Integer wcsTaskNo, Integer roadwaySensorTwo) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setRoadwaySensorTwo = SeconOrder.ROADWAY_SENSOR_TWO;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setRoadwaySensorTwo, roadwaySensorTwo);
    }

    /**
     * 设置坡道传感器1数据
     */
    @RvgLog(value = "设置坡道传感器1数据")
    public void setRampSensorOne(Integer wcsTaskNo, Integer rampSensorOne) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setRampSensorOne = SeconOrder.RAMP_SENSOR_ONE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setRampSensorOne, rampSensorOne);
    }

    /**
     * 设置坡道传感器2数据
     */
    @RvgLog(value = "设置坡道传感器2数据")
    public void setRampSensorTwo(Integer wcsTaskNo, Integer rampSensorTwo) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setRampSensorTwo = SeconOrder.RAMP_SENSOR_TWO;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setRampSensorTwo, rampSensorTwo);
    }

    /**
     * 设置托盘降传感器1数据
     */
    @RvgLog(value = "设置托盘降传感器1数据")
    public void setPalletDownSensorOne(Integer wcsTaskNo, Integer palletDownSensorOne) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setPalletDownSensorOne = SeconOrder.PALLET_DOWN_SENSOR_ONE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setPalletDownSensorOne, palletDownSensorOne);
    }

    /**
     * 设置托盘降传感器2数据
     */
    @RvgLog(value = "设置托盘降传感器2数据")
    public void setPalletDownSensorTwo(Integer wcsTaskNo, Integer palletDownSensorTwo) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setPalleDowntSensorTwo = SeconOrder.PALLET_DOWN_SENSOR_TWO;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setPalleDowntSensorTwo, palletDownSensorTwo);
    }

    /**
     * 设置托盘升传感器1数据
     */
    @RvgLog(value = "设置托盘升传感器1数据")
    public void setPalletUpSensorOne(Integer wcsTaskNo, Integer palletUpSensorOne) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setPalletUpSensorOne = SeconOrder.PALLET_UP_SENSOR_ONE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setPalletUpSensorOne, palletUpSensorOne);
    }

    /**
     * 设置托盘升传感器2数据
     */
    @RvgLog(value = "设置托盘升传感器2数据")
    public void setPalletUpSensorTwo(Integer wcsTaskNo, Integer palletUpSensorTwo) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setPalletUpSensorTwo = SeconOrder.PALLET_UP_SENSOR_TWO;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setPalletUpSensorTwo, palletUpSensorTwo);
    }

    /**
     * 设置传感器误差值
     */
    @RvgLog(value = "设置传感器误差值")
    public void setSensorError(Integer wcsTaskNo, Integer sensorError) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setSensorError = SeconOrder.SENSOR_ERROR;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setSensorError, sensorError);
    }

    /**
     * 设置液压动作高度差
     */
    @RvgLog(value = "设置液压动作高度差")
    public void setHeightDiff(Integer wcsTaskNo, Integer heightDiff) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setHeightDiff = SeconOrder.HEIGHT_DIFF;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setHeightDiff, heightDiff);
    }

    /**
     * 设置液压到位后延迟时间
     */
    @RvgLog(value = "设置液压到位后延迟时间")
    public void setDelayTime(Integer wcsTaskNo, Integer delayTime) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setDelayTime = SeconOrder.DELAY_TIME;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setDelayTime, delayTime);
    }

    /**
     * 设置驱动默认最大速度
     */
    @RvgLog(value = "设置驱动默认最大速度")
    public void setDriveMaxSpeed(Integer wcsTaskNo, Integer driveMaxSpeed) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setDriveMaxSpeed = SeconOrder.DRIVE_MAX_SPEED;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setDriveMaxSpeed, driveMaxSpeed);
    }

    /**
     * 设置驱动默认加速度
     */
    @RvgLog(value = "设置驱动默认加速度")
    public void setDriveAcc(Integer wcsTaskNo, Integer driveAcc) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setDriveAcc = SeconOrder.DRIVE_ACC;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setDriveAcc, driveAcc);
    }

    /**
     * 设置驱动默认减速度
     */
    @RvgLog(value = "设置驱动默认减速度")
    public void setDrivDec(Integer wcsTaskNo, Integer drivDec) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setDrivDec = SeconOrder.DRIVE_DEC;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setDrivDec, drivDec);
    }

    /**
     * 设置溢流调平延迟时间
     */
    @RvgLog(value = "设置溢流调平延迟时间")
    public void setFlatDelay(Integer wcsTaskNo, Integer flatDelay) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setFlatDelay = SeconOrder.FLAT_DELAY;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setFlatDelay, flatDelay);
    }

    /**
     * 设置串联打开时间
     */
    @RvgLog(value = "设置串联打开时间")
    public void setContactOpenTime(Integer wcsTaskNo, Integer contactOpenTime) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setContactOpenTime = SeconOrder.CONTACT_OPEN_TIME;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setContactOpenTime, contactOpenTime);
    }

    /**
     * 设置并联打开时间
     */
    @RvgLog(value = "设置并联打开时间")
    public void setParallelOpenTime(Integer wcsTaskNo, Integer parallelOpenTime) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setParallelOpenTime = SeconOrder.PARALLEL_OPEN_TIME;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setParallelOpenTime, parallelOpenTime);
    }

    /**
     * 设置托盘升绝对编码器数据
     */
    @RvgLog(value = "设置托盘升绝对编码器数据")
    public void setPalletUp(Integer wcsTaskNo, Integer palletUp) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setPalletUp = SeconOrder.PALLET_UP;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setPalletUp, palletUp);
    }

    /**
     * 设置托盘降绝对编码器数据
     */
    @RvgLog(value = "设置托盘降绝对编码器数据")
    public void setPalletDown(Integer wcsTaskNo, Integer palletDown) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setPalletDown = SeconOrder.PALLET_DOWN;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setPalletDown, palletDown);
    }

    /**
     * 设置巷道绝对编码器数据
     */
    @RvgLog(value = "设置巷道绝对编码器数据")
    public void setRoadwayValue(Integer wcsTaskNo, Integer roadwayValue) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setRoadwayValue = SeconOrder.ROADWAY_VALUE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setRoadwayValue, roadwayValue);
    }

    /**
     * 设置坡道绝对编码器数据
     */
    @RvgLog(value = "设置坡道绝对编码器数据")
    public void setRampValue(Integer wcsTaskNo, Integer rampValue) {
        Order setSingleParameter = Order.SET_SINGLE_PARAMETER;
        SeconOrder setRampValue = SeconOrder.RAMP_VALUE;
        actionDebugHandle(wcsTaskNo, setSingleParameter, setRampValue, rampValue);
    }

    /**
     * 保存行驶参数
     */
    @RvgLog(value = "保存行驶参数")
    public void saveDrvingParam(Integer wcsTaskNo) {
        Order saveDrvingParam = Order.SAVE_DRIVING_PARAM;
        SeconOrder getOrReserve = SeconOrder.GET_OR_reserve;
        actionDebugHandle(wcsTaskNo, saveDrvingParam, getOrReserve);
    }

    /**
     * 获取行驶参数
     */
    @RvgLog(value = "获取行驶参数")
    public int getDrvingParam(Integer wcsTaskNo) {
        Order getDrvingParam = Order.GET_DRIVING;
        SeconOrder getOrReserve = SeconOrder.GET_OR_reserve;
        return actionDebugHandle(wcsTaskNo, getDrvingParam, getOrReserve);
    }

    /**
     * 获取res参数
     */
    @RvgLog(value = "获取res参数")
    public int getResParam(Integer wcsTaskNo) {
        Order getResParam = Order.GET_RES;
        SeconOrder getOrReserve = SeconOrder.GET_OR_reserve;
        return actionDebugHandle(wcsTaskNo, getResParam, getOrReserve);
    }

    /**
     * 保存升降参数
     */
    @RvgLog(value = "保存升降参数")
    public void saveLiftParam(Integer wcsTaskNo) {
        Order saveLiftParam = Order.SAVE_LIFT_PARAM;
        SeconOrder getOrReserve = SeconOrder.GET_OR_reserve;
        actionDebugHandle(wcsTaskNo, saveLiftParam, getOrReserve);
    }

    /**
     * 获取升降参数
     */
    @RvgLog(value = "获取升降参数")
    public int getLiftParam(Integer wcsTaskNo) {
        Order getLiftParam = Order.GET_LIFT;
        SeconOrder getOrReserve = SeconOrder.GET_OR_reserve;
        return actionDebugHandle(wcsTaskNo, getLiftParam, getOrReserve);
    }

    /**
     * 获取地图版本
     */
    @RvgLog(value = "获取地图版本")
    public int getMapVersion(Integer wcsTaskNo) {
        Order getMapVersion = Order.GET_MAP_VERSION;
        SeconOrder getOrReserve = SeconOrder.GET_OR_reserve;
        return actionDebugHandle(wcsTaskNo, getMapVersion, getOrReserve);
    }

    /**
     * 获取RES程序版本
     */
    @RvgLog(value = "获取RES程序版本")
    public int getResVersion(Integer wcsTaskNo) {
        Order getResVersion = Order.GET_RES_VERSION;
        SeconOrder getOrReserve = SeconOrder.GET_OR_reserve;
        return actionDebugHandle(wcsTaskNo, getResVersion, getOrReserve);
    }

    /**
     * 获取行驶程序版本
     */
    @RvgLog(value = "获取行驶程序版本")
    public int getDrivingVersion(Integer wcsTaskNo) {
        Order getDrivingVersion = Order.GET_DRIVING_VERSION;
        SeconOrder getOrReserve = SeconOrder.GET_OR_reserve;
        return actionDebugHandle(wcsTaskNo, getDrivingVersion, getOrReserve);
    }

    /**
     * 获取升降程序版本
     */
    @RvgLog(value = "获取升降程序版本")
    public int getLiftVersion(Integer wcsTaskNo) {
        Order getLiftVersion = Order.GET_LIFT_VERSION;
        SeconOrder getOrReserve = SeconOrder.GET_OR_reserve;
        return actionDebugHandle(wcsTaskNo, getLiftVersion, getOrReserve);
    }

    /**
     * 切换校准模式
     * @param wcsTaskNo
     * @param normal
     */
    @RvgLog(value = "切换校准模式")
    public void swicthCalibitionMode(Integer wcsTaskNo, boolean normal) {
        if (normal) {
            actionDebugHandle(wcsTaskNo, Order.SET_SINGLE_PARAMETER, SeconOrder.RES_CALIB,333333);
        } else {
            actionDebugHandle(wcsTaskNo, Order.SET_SINGLE_PARAMETER, SeconOrder.RES_CALIB,444444);
        }
    }

    /**
     * 执行命令
     */
    @RvgLog(value = "执行命令")
    public void actionHandle(Integer wcsTaskNo, Order order) {
        if (rgv.checkRgvType(RgvType.RGV_SEER_COMM)) {
            return;
        }

        int actionNo = getAutoIncrementCmdNum();
        //如果命令为初始化时间指令序号设置为1
        if (order == Order.INITIALIZE) {
            actionNo = 1;
        }
        if (RgvType.FOUR_GENERATIONS.getValue() == rgv.getRgvDB().getRgvType()) {
            Integer cmdStr = order.getOrderByte();
            ActionOrder actionOrder = new ActionOrder(actionNo, cmdStr);
            log.info(rgv.getRgvName() + "发送" + order.getOrderDescribe() + "命令: " + actionOrder);
            actionSendWithResult(wcsTaskNo, actionOrder);
        } else if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
            CmdSendBeanV3 cmdSendBeanV3 = new CmdSendBeanV3(rgvNo, actionNo, order.getOrderByte());
            long time = System.currentTimeMillis();
            senCmd(cmdSendBeanV3);
            if (order.getOrderType() == 1) {
                waitHandleResult(wcsTaskNo, actionNo, time);
            }
        }

    }

    /**
     * 执行命令
     */
    public void actionHandle(Integer wcsTaskNo, Order order, Integer commandParameter) {
        if (rgv.checkRgvType(RgvType.RGV_SEER_COMM)) {
            return;
        }

        if (RgvType.FOUR_GENERATIONS.getValue() == rgv.getRgvDB().getRgvType()) {
            Integer cmdStr = order.getOrderByte();
            int actionNo = getAutoIncrementCmdNum();
            ActionOrder actionOrder = new ActionOrder(actionNo, cmdStr, commandParameter);
            log.info(rgv.getRgvName() + "发送" + order.getOrderDescribe() + "命令: " + actionOrder);
            actionSendWithResult(wcsTaskNo, actionOrder);
        } else if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
            int actionNo = getAutoIncrementCmdNum();
            CmdSendBeanV3 cmdSendBeanV3 = new CmdSendBeanV3(rgvNo, actionNo, order.getOrderByte(), commandParameter);
            long time = System.currentTimeMillis();
            senCmd(cmdSendBeanV3);
            log.info(rgv.getRgvName() + "发送" + order.getOrderDescribe() + "命令: " + cmdSendBeanV3);
            if (order.getOrderType() == 1) {
                waitHandleResult(wcsTaskNo, rgv.getCmdAction().getActionNo(), time);
            }
        }

    }

    /**
     * 路径发送并等待返回结果
     *
     * @param moveOrder
     */
    @RvgLog(value = "路径发送并等待返回结果")
    private void wholeRouteSendWithResult(Integer wcsTaskNo, MoveOrder moveOrder) {
        long sendTime = System.currentTimeMillis();
        if (rgv.getRgvDB().getRgvType() == RgvType.FOUR_GENERATIONS.getValue()) {

            rgv.getRgvHeart().getMoveCommand().offer(moveOrder);
            try {
                WcsHeartThread.doExec(ToRes.getInstance(rgv).heartRequest(ByteBeanUtil.toByte(rgv.getRgvHeart(), rgv.getRgvDB().getRgvNo())));
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (!resReceiveResult(wcsTaskNo, moveOrder, sendTime)) {
                wholeRouteSendWithResult(wcsTaskNo, moveOrder);
            }
        } else if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
            senWholeTask(sendTime, moveOrder);
        } else if (rgv.checkRgvType(RgvType.RGV_SEER_COMM)) {
            List<Node> nodes = moveOrder.getNodeList();
            NodeDBServiceImpl nodeDBService = SpringContextHolder.getBean(NodeDBServiceImpl.class);
            Node startNode = nodes.get(0);
            startNode.setRgv60Point(nodeDBService.getNode(startNode).getRgv60Point());
            ((Rgv60) rgv).getRgvCore().generalTask(rgv.getCurResTaskNo(), moveOrder.getNodeList());
        }

    }

    /**
     * 行驶方法等待执行结果
     *
     * @param taskNo
     * @param sendTime
     */
    @RvgLog(value = "行驶方法等待执行结果")
    public void runWithResult(Integer wcsTaskNo, int taskNo, long sendTime) {
        if (RgvType.FOUR_GENERATIONS.getValue() == rgv.getRgvDB().getRgvType()) {
            int receiveResult = receiveResult(wcsTaskNo, taskNo, sendTime);
            if (receiveResult != 0) {
                rgv.setRgvStatus(RgvStatus.ERROR);
                String message = codeDBService.getCodeDescByFault(receiveResult, CodeType.RES_ERROR_CODE);
                rgv.setErrorMessage(message);
                log.error(rgv.getRgvName() + "命令执行失败：" + taskNo);
                throw new OrderExecuteException(rgvNo, receiveResult, "行驶命令执行失败：" + codeDBService.getCodeDescByFault(receiveResult, CodeType.RES_ERROR_CODE));
            }
        } else if (rgv.checkRgvType(RgvType.FIVE_POINT_FOUR_TL)) {
            waitHandleResult(wcsTaskNo, taskNo, sendTime);
        } else if (rgv.checkRgvType(RgvType.RGV_SEER_COMM)) {
            Rgv60 rgv60 = (Rgv60) rgv;
            LoggerUtil.info(rgv.getRgvName() + "开始等待任务" + wcsTaskNo + "结束", this.getClass());
            while (!rgv60.getRgvCore().isTaskEnd(taskNo)) {
                rgv.checkInterrupt("等待任务结束:" + taskNo, sendTime);
                WcsFuncUtil.delay(50);
            }
            rgv60.analyzeData();
        }
    }


    /**
     * 动作方法
     *
     * @param actionOrder
     */
    @RvgLog(value = "动作方法等待执行结果")
    private void actionSendWithResult(Integer wcsTaskNo, ActionOrder actionOrder) {
        long sendTime = System.currentTimeMillis();
        rgv.getRgvHeart().getActionCommand().offer(actionOrder);
        log.info(rgv.getRgvName() + "开始等待命令接收成功信号,当前命令：" + actionOrder.getCommandNo());
        try {
            WcsHeartThread.doExec(ToRes.getInstance(rgv).heartRequest(ByteBeanUtil.toByte(rgv.getRgvHeart(), rgv.getRgvDB().getRgvNo())));
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (!resReceiveResult(wcsTaskNo, actionOrder, sendTime)) {
            actionSendWithResult(wcsTaskNo, actionOrder);
        }
        int receiveResult = receiveResult(wcsTaskNo, actionOrder, sendTime);
        if (receiveResult == -98) {
            log.error(rgv.getRgvName() + "命令执行超时：" + actionOrder);
            throw new OrderExecuteException(rgvNo, receiveResult, "命令执行超时：" + actionOrder);
        } else if (receiveResult == 2) {
            log.error(rgv.getRgvName() + "指令序号重复: " + actionOrder);
            throw new OrderExecuteException(rgvNo, receiveResult, "指令序号重复: " + codeDBService.getCodeDescByFault(receiveResult, CodeType.RES_ERROR_CODE));
        } else if (receiveResult != 0) {
            log.error(rgv.getRgvName() + "命令执行失败: " + actionOrder);
            throw new OrderExecuteException(rgvNo, receiveResult, "命令执行失败: " + codeDBService.getCodeDescByFault(receiveResult, CodeType.RES_ERROR_CODE));
        }
    }

    public static ToRes getInstance(Rgv rgv) {
        if (rgv == null) {
            throw new IllegalArgumentException("小车对象参数为空");
        }
        ToRes tores = toResMap.get(rgv);
        if (tores == null) {
            Enhancer enhancer = new Enhancer();
            enhancer.setSuperclass(ToRes.class);
            enhancer.setCallback(new LogInterceptorRvg());
            tores = (ToRes) enhancer.create(new Class[]{Rgv.class}, new Object[]{rgv});
            toResMap.put(rgv, tores);
        }
        return tores;
    }

    /**
     * 接收命令执行结束信号
     *
     * @param sendTime
     * @return
     */
    @RvgLog(value = "接收命令执行结束信号")
    private Integer receiveResult(Integer wcsTaskNo, ActionOrder actionOrder, long sendTime) {
        log.info(rgv.getRgvName() + "开始等待命令结束信号,当前命令：" + actionOrder.getCommandNo());
        while (true) {
            rgv.checkInterrupt("ToRes1", sendTime);
            HeartBaseResult receiverResult = ResultContainer.getContainer(rgv).getResult(actionOrder.getCommandNo());
            if (receiverResult != null && receiverResult.getRetDate().getTime() >= sendTime
                    && receiverResult.getCmdResult() != 1 && receiverResult.getCmdResult() != 2) {
                log.info(rgv.getRgvName() + "接收到命令结束信号,当前命令：" + actionOrder.getCommandNo());
                return Integer.valueOf(receiverResult.getCmdResult() != 0 ? receiverResult.getCmdResult() : 0);
            }
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    @RvgLog(value = "接收命令执行结束信号")
    private Integer receiveResult(Integer wcsTaskNo, int taskNo, long sendTime) {
        log.info(rgv.getRgvName() + "开始等待命令结束信号,当前命令：" + taskNo);
        while (true) {
            rgv.checkInterrupt("ToRes2", sendTime);
            HeartBaseResult receiverResult = ResultContainer.getContainer(rgv).getResult(taskNo);
            if (receiverResult != null && receiverResult.getRetDate().getTime() >= sendTime
                    && receiverResult.getTaskResult() != 1 && receiverResult.getTaskResult() != 2) {
                log.info(rgv.getRgvName() + "接收到命令结束信号,当前命令：" + taskNo);
                return Integer.valueOf(receiverResult.getTaskResult() != 0 ? receiverResult.getTaskResult() : 0);
            }
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    /**
     * 接收命令接收到信号
     *
     * @param sendTime
     * @return
     */
    @RvgLog(value = "接收命令接收到信号")
    private boolean resReceiveResult(Integer wcsTaskNo, ActionOrder actionOrder, long sendTime) {
        int count = 0;
        while (true) {
            HeartBaseResult receiverResult = ResultContainer.getContainer(rgv).getResult(actionOrder.getCommandNo());
            if (receiverResult != null && receiverResult.getRetDate().getTime() >= sendTime) {
                if (receiverResult.getCmdResult() == 1 || receiverResult.getCmdResult() == 2) {
                    log.info(rgv.getRgvName() + "RES返回命令接收成功信号,当前命令：" + actionOrder.getCommandNo());
                    return true;
                } else {
                    if (count > 0 && (count % 10) == 0) {
                        //命令从发
                        int times = count / 10;
                        log.info("res命令重发...,  当前第" + times + "次重发, 当前命令:" + actionOrder.getCommandNo());
                        rgv.getRgvHeart().getActionCommand().offer(actionOrder);
                    } else if (count >= 52) {
                        log.info(rgv.getRgvName() + "指令序号" + receiverResult.getCmdResult() +
                                "的指令，未接收到小车接收任务成功，小车返回任务完成，数据交互可能存在丢包，检查网络是否稳定！");
                        if (receiverResult.getCmdResult() == 0) {
                            throw new OrderExecuteException(rgvNo, receiverResult.getCmdResult(), "指令序号" + receiverResult.getCmdResult() +
                                    "的指令，未接收到小车接收任务成功，小车返回任务完成，数据交互可能存在丢包，检查网络是否稳定！");
                        } else {
                            throw new OrderExecuteException(rgvNo, receiverResult.getCmdResult(), codeDBService.getCodeDescByFault(receiverResult.getCmdResult(), CodeType.RES_ERROR_CODE));
                        }
                    }
                }
            }
            if (count == 52) {
                return false;
            }
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            count++;
        }
    }

    //@SaveInterfaceLog(value = "命令接收到信号", sender = "WCS", recipient = "RES")
    @RvgLog(value = "命令接收到信号")
    private boolean resReceiveResult(Integer wcsTaskNo, MoveOrder moveOrder, long sendTime) {
        log.info(rgv.getRgvName() + "开始等待命令接收成功信号,当前命令：" + moveOrder.getTaskNo());
        int count = 0;
        while (true) {
            rgv.checkInterrupt("ToRes4", sendTime);
            HeartBaseResult receiverResult = ResultContainer.getContainer(rgv).getResult(moveOrder.getTaskNo());
            if (receiverResult != null && receiverResult.getRetDate().getTime() >= sendTime) {
                if (receiverResult.getTaskResult() == 1 || receiverResult.getTaskResult() == 2) {
                    log.info(rgv.getRgvName() + "RES返回命令接收成功信号,当前命令：" + moveOrder.getTaskNo());
                    return true;
                } else {
                    if (count > 0 && (count % 10 == 0)) {
                        int times = count / 10;
                        log.info("res命令重发...,  当前第" + times + "次重发, 当前命令:" + moveOrder.getTaskNo());
                        rgv.getRgvHeart().getMoveCommand().offer(moveOrder);
                    } else if (count >= 52) {
                        log.info(rgv.getRgvName() + "指令序号" + receiverResult.getCmdResult() +
                                "的指令，未接收到小车接收任务成功，小车返回任务完成，数据交互可能存在丢包，检查网络是否稳定！");
                        if (receiverResult.getTaskResult() == 0) {
                            throw new OrderExecuteException(rgvNo, receiverResult.getCmdResult(), "指令序号" + receiverResult.getCmdResult() +
                                    "的指令，未接收到小车接收任务成功，小车返回任务完成，数据交互可能存在丢包，检查网络是否稳定！");
                        } else {
                            throw new OrderExecuteException(rgvNo, receiverResult.getTaskResult(), rgv.getRgvName() + "当前指令执行失败，失败任务编号：" + receiverResult.getTaskNo());
                        }
                    }
                }
            }
            // 超过3秒res为接收到则重发
            if (count == 52) {
                return false;
            }
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            count++;
        }
    }

    /**
     * 5.4TL发送整体任务指令并检测结果
     */
    private void senWholeTask(long sendTime, MoveOrder moveOrder) {
        boolean okFlag = false;
        LoggerUtil.info(rgv.getRgvName() + "等待任务接收成功!", this.getClass());
        while (!okFlag) {
            rgv.checkInterrupt("5.4T-ToRes5", sendTime);
            try {
                RgvTaskSendMessage rgvTaskSendMessage = new RgvTaskSendMessage(rgv, moveOrder,
                        RgvMessageType.analyzeRgvTaskMessageType());
                rgvTaskSendMessage.setMessgeTime(sendTime);
                rgv.getRgvProtocol().comm(rgvTaskSendMessage);

                if (rgv.getTaskAction().getActionStatus() == RgvActionStatus.RGV_DOING_ACTION) {
                    LoggerUtil.info(rgv.getRgvName() + "任务接收成功!", this.getClass());
                    okFlag = true;
                }
            } catch (IOException e) {
                okFlag = false;
                WcsUtil.delay(1000);
                continue;
            }
        }
    }

    /**
     * 发送指令并检测结果
     *
     * @param cmdSendBeanV3
     */
    private int senCmd(CmdSendBeanV3 cmdSendBeanV3) {
        boolean okFlag = false;
        RgvBaseMessage recMessage = null;
        long sendTime = System.currentTimeMillis();
        int count = 10;
        while (!okFlag) {
            rgv.checkInterrupt("5.4T-ToRes6", sendTime);
            try {
                recMessage = rgv.getRgvProtocol().comm(new RgvCommandSendMessage(rgv,
                        cmdSendBeanV3.getTaskNo(), cmdSendBeanV3.getCmdNo(), cmdSendBeanV3.getCmd(), cmdSendBeanV3.getCmdParam()));
                okFlag = true;
            } catch (IOException e) {
                WcsUtil.exceptionLog(e, this.getClass());
                if (count > 0) {
                    okFlag = false;
                    count--;
                    WcsUtil.delay(1000);
                } else {
                    throw new RuntimeException("指令发送失败，" + rgv.getRgvName() + "无返回，请检查小车是否正常，网络是否正常");
                }
            }
        }

        if (recMessage == null) {
            return 0xFFFFFFFF;
        }

        if (recMessage instanceof RgvCommandRecMessage) {
            return ((RgvCommandRecMessage) recMessage).getResultParam();
        }

        throw new RuntimeException(rgv.getRgvName() + "指令返回数据错误");
    }

    /**
     * 发送指令并检测结果
     *
     * @param cmdSendBeanV3
     */
    private long senRFIDCmd(CmdSendBeanV3 cmdSendBeanV3) {
        boolean okFlag = false;
        RgvBaseMessage recMessage = null;
        long sendTime = System.currentTimeMillis();
        int count = 10;
        while (!okFlag) {
            rgv.checkInterrupt("5.4T-ToRes6", sendTime);
            try {
                recMessage = rgv.getRgvProtocol().comm(new RgvCommandSendMessage(rgv,
                        cmdSendBeanV3.getTaskNo(), cmdSendBeanV3.getCmdNo(), cmdSendBeanV3.getCmd(), cmdSendBeanV3.getCmdParam()));
                okFlag = true;
            } catch (IOException e) {
                WcsUtil.exceptionLog(e, this.getClass());
                if (count > 0) {
                    okFlag = false;
                    count--;
                    WcsUtil.delay(1000);
                } else {
                    throw new RuntimeException("指令发送失败，" + rgv.getRgvName() + "无返回，请检查小车是否正常，网络是否正常");
                }
            }
        }

        if (recMessage == null) {
            return 0xFFFFFFFF;
        }

        if (recMessage instanceof RgvCommandRecMessage) {
            return ((RgvCommandRecMessage) recMessage).getRFIDResultParam();
        }

        throw new RuntimeException(rgv.getRgvName() + "指令返回数据错误");
    }

    /**
     * 等待命令执行结束
     *
     * @param actionNo
     */
    public void waitHandleResult(Integer wcsTaskNo, int actionNo, long time) {
        while (true) {
            WcsUtil.delay(100);
            rgv.checkInterrupt("ToRes,等待结束信号" + actionNo, time);
            RgvBaseMessage rgvBaseMessage = ResultContainer.getContainer(rgv).getReceiveMessage(actionNo);

            if (rgvBaseMessage == null) {
                continue;
            }

            if (!(rgvBaseMessage instanceof RgvLifeRecMessage)) {
                throw new RuntimeException("RgvLifeRecMessage != " + rgvBaseMessage.toString());
            }

            RgvLifeRecMessage rgvLifeRecMessage = (RgvLifeRecMessage) rgvBaseMessage;

            // 2代表执行完成
            if (rgvLifeRecMessage != null && rgvLifeRecMessage.getMessgeTime() > time) {
                if (rgvLifeRecMessage.getResult() == 2) {
                    log.info("执行成功" + rgvLifeRecMessage);
                    break;
                    // 1代表执行中
                } else if (rgvLifeRecMessage.getResult() != 1) {
                    rgv.getCmdAction().initStatus();
                    throw new OrderExecuteException(rgvNo, rgvLifeRecMessage.getResult(), codeDBService.getCodeDescByFault(rgvLifeRecMessage.getResult(), CodeType.RES_ERROR_CODE));
                }
            }
        }
    }

    /**
     * 获取任务序号
     */
    private volatile Integer lasTaskNum;
    public synchronized int getAutoIncrementTaskNum() {
        Integer cacheObject = redisCache.getCacheObject(rgv.getRgvName());
        if (cacheObject == null) {
            redisCache.setCacheObject(rgv.getRgvName(), 2);
            return 2;
        }
        if (cacheObject >= 254) {
            redisCache.setCacheObject(rgv.getRgvName(), 3);
            return 3;
        }

        int taskNum = cacheObject + 1;
        if (lasTaskNum == null) {
            lasTaskNum = taskNum;
        } else if (lasTaskNum == taskNum) {
            lasTaskNum++;
            taskNum = lasTaskNum;
        } else {
            lasTaskNum = taskNum;
        }

        if (taskNum >= 254) {
            taskNum = 3;
        }
        redisCache.setCacheObject(rgv.getRgvName(), taskNum);
        return taskNum;
    }

    /**
     * 获取指令序号
     */
    private volatile Integer lasCmdNum;
    public synchronized int getAutoIncrementCmdNum() {
        String key = rgv.getRgvName() + "指令";
        Integer cacheObject = redisCache.getCacheObject(key);
        if (cacheObject == null) {
            redisCache.setCacheObject(key, 2);
            return 2;
        }
        if (cacheObject >= 254) {
            redisCache.setCacheObject(key, 3);
            return 3;
        }

        int cmdNum = cacheObject + 1;
        if (lasCmdNum == null) {
            lasCmdNum = cmdNum;
        } else if (lasCmdNum == cmdNum) {
            lasCmdNum++;
            cmdNum = lasCmdNum;
        } else {
            lasCmdNum = cmdNum;
        }

        if (cmdNum >= 254) {
            cmdNum = 3;
        }
        redisCache.setCacheObject(key, cmdNum);
        return cmdNum;
    }

    public String getBACmdParam() {
        CmdSendBeanV3 cmdSendBeanV3 = new CmdSendBeanV3(rgvNo, getAutoIncrementCmdNum(), Order.BA.getOrderByte(),0);
        return String.valueOf(senRFIDCmd(cmdSendBeanV3));
    }

    /**
     * 执行命令
     */
    @RvgLog(value = "执行命令")
    public int actionDebugHandle(Integer wcsTaskNo, Order order, SeconOrder seconOrder) {
        int actionNo;
        if (wcsTaskNo == null) {
            actionNo = getAutoIncrementCmdNum();
        } else {
            actionNo = wcsTaskNo;
        }
        if (RgvType.FIVE_POINT_FOUR_TL.getValue() == rgv.getRgvDB().getRgvType()) {
            DebugCmdSendBeanV3 debugCmdSendBeanV3 = new DebugCmdSendBeanV3(rgvNo, actionNo, order.getOrderByte(),
                    seconOrder.getOrderByte());
            long time = System.currentTimeMillis();
            int result = sendDebugCmd(debugCmdSendBeanV3, 5);
            log.info(rgv.getRgvName() + "发送" + order.getOrderDescribe() + "命令: " + debugCmdSendBeanV3);
            if (order.getOrderType() == 1) {
                waitHandleResult(wcsTaskNo, rgv.getCmdAction().getActionNo(), time);
            }

            return result;
        } else {
            throw new IllegalArgumentException("当前车型不支持发送调试指令");
        }

    }

    /**
     * 执行命令
     */
    public void actionDebugHandle(Integer wcsTaskNo, Order order, SeconOrder seconOrder, Integer commandParameter) {
        int actionNo;
        if (wcsTaskNo == null || wcsTaskNo == 0) {
            actionNo = getAutoIncrementCmdNum();
        } else {
            actionNo = wcsTaskNo;
        }

        DebugCmdSendBeanV3 debugCmdSendBeanV3 = new DebugCmdSendBeanV3(rgvNo, actionNo, order.getOrderByte(),
                seconOrder.getOrderByte(), commandParameter);
        long time = System.currentTimeMillis();
        sendDebugCmd(debugCmdSendBeanV3, 5);
        log.info(rgv.getRgvName() + "发送" + order.getOrderDescribe() + "命令: " + debugCmdSendBeanV3);
        if (order.getOrderType() == 1) {
            waitHandleResult(wcsTaskNo, rgv.getCmdAction().getActionNo(), time);
        }
    }

    /**
     * 发送指令并检测结果
     *
     * @param debugCmdSendBeanV3
     */
    private int sendDebugCmd(DebugCmdSendBeanV3 debugCmdSendBeanV3, int count) {
        RgvDebugCmdSendMessage sendMessage = new RgvDebugCmdSendMessage(rgv, debugCmdSendBeanV3.getCmdNo(),
                debugCmdSendBeanV3.getCmd(), debugCmdSendBeanV3.getSeconCmd(), debugCmdSendBeanV3.getCmdParam());
        boolean okFlag = false;
        RgvBaseMessage recMessage = null;
        long sendTime = System.currentTimeMillis();
        while (!okFlag) {
            rgv.checkInterrupt("5.4T-ToRes6", sendTime);
            try {
                recMessage = rgv.getRgvProtocol().comm(sendMessage);
                okFlag = true;
            } catch (IOException e) {
                WcsUtil.exceptionLog(e, this.getClass());
                if (count > 0) {
                    okFlag = false;
                    count--;
                    WcsUtil.delay(1000);
                } else {
                    throw new RuntimeException("指令发送失败，" + rgv.getRgvName() + "无返回，请检查小车是否正常，网络是否正常");
                }
            }
        }

        if (recMessage == null) {
            return 0xFFFFFFFF;
        }

        if (recMessage instanceof RgvCommandRecMessage) {
            return ((RgvCommandRecMessage) recMessage).getResultParam();
        }

        if (recMessage instanceof RgvDebugCmdRecMessage) {
            if (sendMessage.getCmd() == DebugCommType.LIFT_PARAM.getcode()) {
                return ((RgvDebugCmdRecMessage) recMessage).getResultParam(DebugCommType.LIFT_PARAM);
            } else if (sendMessage.getCmd() == DebugCommType.RES_PARAM.getcode()) {
                return ((RgvDebugCmdRecMessage) recMessage).getResultParam(DebugCommType.RES_PARAM);
            } else if (sendMessage.getCmd() == DebugCommType.DRIVING_PARAM.getcode()) {
                if(debugCmdSendBeanV3.getSeconCmd() == 0){
                    return ((RgvDebugCmdRecMessage) recMessage).getResultParam(DebugCommType.DRIVING_PARAM);
                }else {
                    return ((RgvDebugCmdRecMessage) recMessage).getResultParam(DebugCommType.SET_ONE_PARAM);
                }
            } else if (sendMessage.getCmd() == DebugCommType.GET_RES_VERSION.getcode()) {
                return ((RgvDebugCmdRecMessage) recMessage).getResultParam(DebugCommType.GET_RES_VERSION);
            } else {
                return ((RgvDebugCmdRecMessage) recMessage).getResultParam(DebugCommType.SET_ONE_PARAM);
            }

        }

        throw new RuntimeException(rgv.getRgvName() + "指令返回数据错误");
    }

}
